package assignment5;

import java.util.Scanner;

import javax.swing.JOptionPane;

public class HumanPlayer extends Player {

	@Override
	public String getName() {
		return "Dave";
	}

	@Override
	public Move makeAmove(PlayerPot pot) {
		// show the user the current state of the game
		pot.printPlayerCards();
		MainNoThanks.your.setText("Chips in the pot: " + pot.getNumChips() +
				"\nUp card: " + pot.getUpCard() + "\nYour chips: " + this.getNumChips() + 
				"\nYour cards: " + this.getCards());

		if (this.getNumChips() == 0) {
			 JOptionPane.showMessageDialog(null, "Uh oh! You have no chip left so you must take it!", "Alert!", JOptionPane.ERROR_MESSAGE);
			return Move.takeIt;
		} else {
			while (true) {
				Integer selectedValue = JOptionPane.showConfirmDialog(null,"Would you like to take the card?",
						"Option", JOptionPane.YES_NO_OPTION);
				
				if (selectedValue == 0) {
					return Move.takeIt;
				} else {
					return Move.noThanks;
				}
			}
		}
	}
}
